package dao;

import org.apache.ibatis.annotations.*;
import pojo.Zz;

import java.util.List;

@Mapper
/**
 * 症状表数据访问接口
 */
public interface ZzMapper {
    // 根据id查询症状
    @Select("SELECT id, name, description FROM zz WHERE id = #{id}")
    Zz findZzById(Integer id);

    // 查询所有症状
    @Select("SELECT id, name, description FROM zz")
    List<Zz> findAllZz();

    // 根据症状名称查询
    @Select("SELECT id, name, description FROM zz WHERE name = #{name}")
    Zz findZzByName(String name);

    // 模糊搜索症状
    @Select("SELECT id, name, description FROM zz WHERE name LIKE CONCAT('%', #{keyword}, '%')")
    List<Zz> searchZz(String keyword);

    // 新增症状
    @Insert("INSERT INTO zz (name, description) VALUES (#{name}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int addZz(Zz zz);

    // 更新症状
    @Update("UPDATE zz SET name = #{name}, description = #{description} WHERE id = #{id}")
    int updateZz(Zz zz);

    // 删除症状
    @Delete("DELETE FROM zz WHERE id = #{id}")
    int deleteZz(Integer id);
}